<template>
  <div class="page-login">
    <vue-particles
      color="#fff"
      :particleOpacity="0.7"
      :particlesNumber="80"
      shapeType="circle"
      :particleSize="4"
      linesColor="#dedede"
      :linesWidth="1"
      :lineLinked="true"
      :lineOpacity="0.4"
      :linesDistance="150"
      :moveSpeed="3"
      :hoverEffect="true"
      hoverMode="grab"
      :clickEffect="true"
      clickMode="push"
    />

    <main class="login-form">
      <h1>江苏生物多样性数据搜索平台</h1>
      <el-form ref="form" :model="form">
        <el-form-item>
          <el-input v-model="form.username" placeholder="手机号/账号" autocomplete="off" ></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="form.password" placeholder="手机号/账号" type="password" autocomplete="off"></el-input>
        </el-form-item>
        <div class="form-footer">
          <el-button type="primary" @click="onSubmit" style="width: 100%">登录</el-button>
          <p>没有账号？<router-link :to="{name: 'Login'}">立即注册</router-link></p>
        </div>
      </el-form>
    </main>

  </div>
</template>

<script>
export default {
  name: "PageLogin",
  data() {
    return {
      form: {
        username: '',
        password: '',
      },
    }
  },
  methods: {
    onSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$router.push({
            name: 'Home',
          })
        } else {
          return false
        }
      })
    },
  },
};
</script>

<style lang="scss">
.page-login{
  position: relative;
  height: 100vh;
  background: url(../../assets/images/login_bg.jpg) no-repeat center center #000;
  background-size: cover;
  .login-form{
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    border-radius: 10px;
    background-color: rgba(255,255,255, .5);

    & > h1{
      font-size: 24px;
      margin-bottom: 20px;
      color: var(--primary-color);
    }

    .form-footer{
      & > p {
        margin-top: 8px;
        text-align: center;
      }
    }
  }
}
</style>